﻿using XCore.Authorization;

namespace SaaS.Core.Authorization
{
    public class PermissionAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            #region 授权模块（平台管理）

            var auth = context.CreatePermission(PermissionNames.Permission, "权限管理");

            var user = auth.CreateChildPermission(PermissionNames.Permission_User, "用户管理");
            user.CreateChildPermission(PermissionNames.User_Create, "新增");
            user.CreateChildPermission(PermissionNames.User_Edit, "编辑");
            user.CreateChildPermission(PermissionNames.User_Delete, "删除");
            user.CreateChildPermission(PermissionNames.User_Authoriza, "授权");

            var role = auth.CreateChildPermission(PermissionNames.Permission_Role, "角色管理");
            role.CreateChildPermission(PermissionNames.Permission_Role_Create, "创建");
            role.CreateChildPermission(PermissionNames.Permission_Role_Edit, "编辑");
            role.CreateChildPermission(PermissionNames.Permission_Role_Delete, "删除");
            role.CreateChildPermission(PermissionNames.Permission_Role_Authoriza, "授权");

            var organizationUnit = auth.CreateChildPermission(PermissionNames.Permission_OrganizationUnit, "机构管理");
            organizationUnit.CreateChildPermission(PermissionNames.OrganizationUnit_Create, "创建");
            organizationUnit.CreateChildPermission(PermissionNames.OrganizationUnit_Edit, "编辑");
            organizationUnit.CreateChildPermission(PermissionNames.OrganizationUnit_Delete, "删除");
            organizationUnit.CreateChildPermission(PermissionNames.OrganizationUnit_Query, "查询");
            #endregion
        }
    }
}
